<script>
	import globalData from './common/js/globalData.js';
	import user from './common/js/user.js';
	var timer;
	export default {
		globalData: {},
		onLaunch: function(options) {
			// uni.showModal({
			// 	title:'提示',
			// 	content:JSON.stringify(options)
			// })
			let titleHeight = 64;
			let statusBarHeight = 22;
			let naviBarHeight = 44;
			const res = uni.getSystemInfoSync();
			const system = res.platform;
			statusBarHeight = res.statusBarHeight;
			if (system === 'android') {
				titleHeight = 40 + statusBarHeight;
			} else if (system === 'ios') {
				titleHeight = 44 + statusBarHeight;
			} else if (system === 'devtools') {
				titleHeight = 44 + statusBarHeight;
			}
			naviBarHeight = titleHeight - statusBarHeight;
			this.globalData.statusBarHeight = statusBarHeight;
			this.globalData.naviBarHeight = naviBarHeight;
			this.globalData.titleHeight = titleHeight;
			this.globalData.windowHeight = res.windowHeight;
			this.globalData.windowWidth = res.windowWidth;
			this.globalData.iphoneX = ((system === 'ios'||system=='devtools') && res.screenHeight >= 812) ? true : false;
			this.globalData.platform = res.platform;
			if (options.query && options.query.qrCode) {
			      this.globalData.qrCode = options.query.qrCode;
			}  
			// #ifdef APP-PLUS || APP-PLUS-NVUE
			let second = 5
			
			console.log(user.getUserInfo())
			timer = setInterval(() => {
				second--
				if (second <= 0) {
					clearInterval(timer)
					plus.navigator.closeSplashscreen()
				}
			}, 1000)
			if (user.getUserInfo()) {
				uni.reLaunch({
					url: '/pages/index/index',
					success: () => {
						//跳转完页面后再关闭启动页
						plus.navigator.closeSplashscreen();
					}
				})
			} else {
				clearInterval(timer)
				uni.reLaunch({
					url: '/pages/login/login',
					success: () => {
						plus.navigator.closeSplashscreen()
					}
				})
			}
			// #endif
			// // #ifdef MP
			// if (user.getUserInfo()) {
			// 	uni.reLaunch({
			// 		url: '/pages/index/index',
			// 		success: () => {}
			// 	})
			// } else {
			// 	uni.reLaunch({
			// 		url: '/pages/login/login'
			// 	})
			// }
			// // #endif
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import url("common/css/base.css");
	/*每个页面公共css */
	@import "uview-ui/index.scss";

	/* #ifdef MP-WEIXIN || APP-PLUS */
	::-webkit-scrollbar {
		display: none;
		width: 0 !important;
		height: 0 !important;
		-webkit-appearance: none;
		background: transparent;
		color: transparent;
	}
	/* #endif */
	page {
		background-color: #F3F4F6;
	}
</style>
